package com.hsyt.pms.sys.dubbo.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.hsyt.pfc.support.rpc.PageResult;
import com.hsyt.pms.api.dto.system.SysParamDto;
import com.hsyt.pms.api.vo.system.SysParamVo;
import com.hsyt.pms.orm.sys.SysParamDao;
import com.hsyt.pms.sys.dubbo.SysUserService;
import com.hsyt.pms.sys.dubbo.SysParamService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.alibaba.dubbo.config.annotation.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName: SysParamServiceImpl
 * @Description: 系统参数
 * @author wangze@hsyuntai.com
 * @date 2019年2月12日 下午2:45:51
 */
@Slf4j
@Component
@Service(version = "0.0.1", interfaceClass = SysParamService.class, registry = "pms", group = "pmsSystem", timeout = 3000)
public class SysParamServiceImpl implements SysParamService {

    private static final Logger LOGGER = LoggerFactory.getLogger(SysParamServiceImpl.class);

    @Resource
    private SysParamDao sysParamDao;

    public int updateByPrimaryKey(SysParamDto sysParamDto) {
        return this.sysParamDao.updateByPrimaryKey(sysParamDto);
    }

    @Override
    public PageResult<SysParamVo> searchPageDataByDto(SysParamDto dto) {
        Page<?> page = PageHelper.startPage(dto.getPageNumber(), dto.getPageSize(), true);
        List<SysParamVo> list = sysParamDao.queryParamByDto(dto);
        PageResult<SysParamVo> pageResult = PageResult.create(page.getTotal(), list);
        return pageResult;
    }

    @Override
    public void addParam(SysParamDto dto) {
        sysParamDao.insert(dto);
    }

}
